var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("SDK"),
    i = (function () {
        function e() {}
        return (
            (e.getInstance = function () {
                return e.instance || (e.instance = new e()), e.instance;
            }),
            (e.prototype.initGameConfig = function (e) {
                var t = this;
                cc.resources.load("sdk/config/gameConfig", cc.JsonAsset, function (o, n) {
                    if (o) console.error("Failed to load JSON:", o);
                    else {
                        var i = n.json;
                        i.sort(function (e, t) {
                            return e.gameID - t.gameID;
                        }),
                            (t.gameList = i),
                            console.log("this.json:", JSON.stringify(i)),
                            e(i);
                    }
                });
            }),
            (e.prototype.getGameList = function () {
                return this.gameList;
            }),
            (e.prototype.startDefaultGame = function () {
                var e = this.gameList[0],
                    t = e.gameID,
                    o = e.gameCode,
                    n = e.collisionData,
                    i = e.gameLoad;
                this.startGame(t, o, n, i);
            }),
            (e.prototype.startGame = function (e, t, o, i) {
                console.log("change game, gameID: " + e + ", gameCode: " + t),
                    (window.gameResourcePrefix = t),
                    window.systemCollisionManager
                        ? ((cc.director._collisionManager.enabled = !1),
                          (cc.director._collisionManager = window.systemCollisionManager))
                        : (window.systemCollisionManager = cc.director._collisionManager),
                    this.updateCollisionData(o),
                    (n.default.Instance.gameID = e),
                    n.default.Instance.isPortrait() && n.default.Instance.hideBanner(),
                    cc.director.loadScene(i);
            }),
            (e.prototype.updateCollisionData = function (e) {
                var t = cc.game.groupList,
                    o = t.length,
                    n = Array.from({length: o}, function () {
                        return Array(o).fill(!1);
                    });
                console.log(t);
                for (var i = 0; i < e.length; i++) {
                    var a = e[i],
                        r = a[0],
                        s = a[1];
                    console.log("groupNameA = " + r + " groupNameB = " + s);
                    var c = t.indexOf(r),
                        l = t.indexOf(s);
                    (n[c][l] = !0), (n[l][c] = !0);
                }
                cc.game.collisionMatrix = n;
            }),
            e
        );
    })();
o.default = i;
